home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_qt.idb / usr / freeware / include / Qt / qfontmetrics.h.z / qfontmetrics.h
Encoding:
C/C++ Source or Header  |  1998-10-28  |  3.0 KB  |  111 lines

  1. /****************************************************************************
  2. ** $Id: qfontmetrics.h,v 2.15 1998/07/03 00:09:33 hanord Exp $
  3. **
  4. ** Definition of QFontMetrics class
  5. **
  6. ** Created : 940514
  7. **
  8. ** Copyright (C) 1992-1998 Troll Tech AS.  All rights reserved.
  9. **
  10. ** This file is part of Qt Free Edition, version 1.40.
  11. **
  12. ** See the file LICENSE included in the distribution for the usage
  13. ** and distribution terms, or http://www.troll.no/free-license.html.
  14. **
  15. ** IMPORTANT NOTE: You may NOT copy this file or any part of it into
  16. ** your own programs or libraries.
  17. **
  18. ** Please see http://www.troll.no/pricing.html for information about 
  19. ** Qt Professional Edition, which is this same library but with a
  20. ** license which allows creation of commercial/proprietary software.
  21. **
  22. *****************************************************************************/
  23.  
  24. #ifndef QFONTMETRICS_H
  25. #define QFONTMETRICS_H
  26.  
  27. #ifndef QT_H
  28. #include "qfont.h"
  29. #include "qrect.h"
  30. #endif // QT_H
  31.  
  32.  
  33. class QFontMetrics
  34. {
  35. public:
  36.     QFontMetrics( const QFont & );
  37.     QFontMetrics( const QFontMetrics & );
  38.    ~QFontMetrics();
  39.  
  40.     QFontMetrics &operator=( const QFontMetrics & );
  41.  
  42.     int        ascent()    const;
  43.     int        descent()    const;
  44.     int        height()    const;
  45.     int        leading()    const;
  46.     int        lineSpacing()    const;
  47.     int        minLeftBearing() const;
  48.     int        minRightBearing() const;
  49.     int        maxWidth()    const;
  50.  
  51.     bool    inFont(char)    const;
  52.  
  53.     int        leftBearing(char) const;
  54.     int        rightBearing(char) const;
  55.     int        width( const char *, int len = -1 ) const;
  56.     int        width( char ) const;
  57.     QRect    boundingRect( const char *, int len = -1 ) const;
  58.     QRect    boundingRect( char ) const;
  59.     QRect    boundingRect( int x, int y, int w, int h, int flags,
  60.                   const char *str, int len=-1, int tabstops=0,
  61.                   int *tabarray=0, char **intern=0 ) const;
  62.     QSize    size( int flags,
  63.               const char *str, int len=-1, int tabstops=0,
  64.               int *tabarray=0, char **intern=0 ) const;
  65.  
  66.     int        underlinePos()    const;
  67.     int        strikeOutPos()    const;
  68.     int        lineWidth()    const;
  69.  
  70. #if 1    /* OBSOLETE */
  71.     const QFont &font() const;
  72. #endif
  73.  
  74. private:
  75.     QFontMetrics( const QWidget * );
  76.     QFontMetrics( const QPainter * );
  77.     static void reset( const QWidget * );
  78.     static void reset( const QPainter * );
  79.     const QFontDef *spec() const;
  80. #if defined(_WS_WIN_)
  81.     void *textMetric() const;
  82.     HDC hdc() const;
  83. #elif defined(_WS_X11_)
  84.     void *fontStruct() const;
  85.     int printerAdjusted(int) const;
  86. #endif
  87.  
  88.     enum Type { FontInternal, Widget, Painter };
  89.     union {
  90.     int   flags;
  91.     void *dummy;
  92.     } t;
  93.     union {
  94.     QFontInternal *f;
  95.     QWidget          *w;
  96.     QPainter      *p;
  97.     } u;
  98.  
  99.     int        type()         const { return t.flags & 0xff; }
  100.     bool    underlineFlag()  const { return (t.flags & 0x100) != 0; }
  101.     bool    strikeOutFlag()  const { return (t.flags & 0x200) != 0; }
  102.     void    setUnderlineFlag()       { t.flags |= 0x100; }
  103.     void    setStrikeOutFlag()       { t.flags |= 0x200; }
  104.  
  105.     friend class QWidget;
  106.     friend class QPainter;
  107. };
  108.  
  109.  
  110. #endif // QFONTMETRICS_H
  111.